{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "函数名称|说明\n",
    ":-:| :-:\n",
    "get_option()|取解释器的默认参数值。\n",
    "set_option()|改解释器的默认参数值。\n",
    "reset_option()|释器的参数重置为默认值。\n",
    "describe_option()|出参数的描述信息。\n",
    "option_context()|临时时设置解释器参数，当退出使用的语句块时，恢复为默认值。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "60\n"
     ]
    }
   ],
   "source": [
    "# 显示上限行数\n",
    "print (pd.get_option(\"display.max_rows\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "40\n"
     ]
    }
   ],
   "source": [
    "# 显示上限列数\n",
    "print (pd.get_option(\"display.max_columns\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100\n"
     ]
    }
   ],
   "source": [
    "# 修改上限行数\n",
    "pd.set_option(\"display.max_rows\",100)\n",
    "print (pd.get_option(\"display.max_rows\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100\n"
     ]
    }
   ],
   "source": [
    "# 修改上限列数\n",
    "pd.set_option(\"display.max_columns\",100)\n",
    "print (pd.get_option(\"display.max_columns\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "60\n"
     ]
    }
   ],
   "source": [
    "# 重置行列上限\n",
    "pd.reset_option(\"display.max_rows\")\n",
    "print(pd.get_option(\"display.max_rows\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "display.max_rows : int\n",
      "    If max_rows is exceeded, switch to truncate view. Depending on\n",
      "    `large_repr`, objects are either centrally truncated or printed as\n",
      "    a summary view. 'None' value means unlimited.\n",
      "\n",
      "    In case python/IPython is running in a terminal and `large_repr`\n",
      "    equals 'truncate' this can be set to 0 and pandas will auto-detect\n",
      "    the height of the terminal and print a truncated object which fits\n",
      "    the screen height. The IPython notebook, IPython qtconsole, or\n",
      "    IDLE do not run in a terminal and hence it is not possible to do\n",
      "    correct auto-detection.\n",
      "    [default: 60] [currently: 60]\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 获取描述\n",
    "pd.describe_option(\"display.max_rows\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "60\n"
     ]
    }
   ],
   "source": [
    "# option_context() 上下文管理器，用于临时设置 with 语句块中的默认显示参数。\n",
    "# 当您退出 with 语句块时，参数值会自动恢复。示例如下：\n",
    "\n",
    "with pd.option_context(\"display.max_rows\",10):\n",
    "   print(pd.get_option(\"display.max_rows\"))\n",
    "print(pd.get_option(\"display.max_rows\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "参数|说明\n",
    ":- | :-\n",
    "display.max_rows|最大显示行数，超过该值用省略号代替，为None时显示所有行。\n",
    "display.max_columns|最大显示列数，超过该值用省略号代替，为None时显示所有列。\n",
    "display.expand_frame_repr|输出数据宽度超过设置宽度时，表示是否对其要折叠，False不折叠，True要折叠。\n",
    "display.max_colwidth|单列数据宽度，以字符个数计算，超过时用省略号表示。\n",
    "display.precision|设置输出数据的小数点位数。\n",
    "display.width|数据显示区域的宽度，以总字符数计算。\n",
    "display.show_dimensions|当数据量大需要以truncate（带引号的省略方式）显示时，该参数表示是否在最后显示数据的维数，默认 True 显示，False 不显示。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
